using UnityEngine;
using System.Collections;
using System;

public class Brodcast : MonoBehaviour
{
	string tf1;
	string tf2;
	public string nome;
	public int logado = 0;
	
	void OnGUI()
	{
		if(Network.peerType != NetworkPeerType.Disconnected && logado == 1)
		{
			if (GUI.Button(new Rect(10,95,100,20), "Chat")) 
			{
				try
				{
   					networkView.RPC("BroadcastCL", RPCMode.All,(nome + ": " +tf1));
				}
				
				catch(Exception e)
				{
					Debug.Log(e.ToString());
				}
			}
			
			tf2 = GUI.TextField(new Rect(10, 120, 200, 20), tf2);
		}
	}
		
		[RPC]
		
		void BroadcastCL(String recebido)
		{
 			tf2 = recebido;
		}
}